package com.yanqu.road.server.cmd.monopolymarket;

import com.yanqu.road.pb.monopolymarket.MonopolyMarketProto;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.Command;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.monopolymarket.MonopolyMarketMgr;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.GameProtocol;
import io.netty.channel.ChannelHandlerContext;

/**
 * @Description 这种加战报 有可能区服不在线 导致没加入成功
 * @Author cwq
 * @Data 2021/8/20 10:25
 */
@Cmd(code = GameProtocol.S_MONOPOLY_MARKET_SYN_ATTACK, desc = "榷场同步玩家攻击信息  跨服返回区服 协议")
public class MonopolyMarketSynAttackFromCrossCmd implements Command {

    @Override
    public void execute(ChannelHandlerContext ctx, YanQuMessage packet) throws Exception {
        MonopolyMarketProto.MonopolyMarketSynAttackToGameServerMsg reqMsg = MonopolyMarketProto.MonopolyMarketSynAttackToGameServerMsg.parseFrom(packet.getBytes());
        GamePlayer player = GamePlayerMgr.getOnlinePlayer(reqMsg.getRobedId());
        MonopolyMarketMgr.addReport(player,reqMsg);
        if(player != null){
            MonopolyMarketMgr.refreshUser(player,true,true);
        }
    }
}
